<template>
  <ve-bar :data="chartData" :extend="extend" :settings="chartSettings"></ve-bar>
</template>

<script>

export default {
  props: ['userId'],
  data () {
    this.chartSettings = {
      axisSite: { bottom: ['得分'] }
    }
    this.extend = {
      series: {
        label: { show: true, position: 'right' },
        itemStyle: { color: '#ED6E87' }
      }
    }
    return {
      chartData: {
        columns: ['MBTI倾向', '得分'],
        rows: [
          { MBTI倾向: '(P) 知觉', 得分: 0 },
          { MBTI倾向: '(F) 情感', 得分: 0 },
          { MBTI倾向: '(N) 直觉', 得分: 0 },
          { MBTI倾向: '(I) 内向', 得分: 0 }
        ]
      }
    }
  },

  created () {
    this.selectproresult()
  },
  methods: {
    selectproresult () {
      const params = {
        user_Id: this.userId,
        questionType_Id: 1
      }
      this.selectProresult(params)
        .then(data => {
          // console.log(data.data[0].resultStrength)
          this.chartData.rows[0].得分 = JSON.parse(data.data[0].countScore).P
          this.chartData.rows[1].得分 = JSON.parse(data.data[0].countScore).F
          this.chartData.rows[2].得分 = JSON.parse(data.data[0].countScore).N
          this.chartData.rows[3].得分 = JSON.parse(data.data[0].countScore).I
          this.$emit('resultStrengthMBTI', data.data[0].resultStrength)
        })
    }
  }
}
</script>
